package com.qf.chinatelcom.apiinterface.controller.advice;

import com.qianfeng.smsplatform.common.dto.R;
import com.qianfeng.smsplatform.common.exceptions.MyBaseException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice//这个注解相当于三个注解的结合
public class MyControllerAdvice {
    /**
     * 捕获我们自己设定的异常
     * @param e
     * @return
     */
    @ExceptionHandler(MyBaseException.class)
    public R processBaseException(MyBaseException e){
        return R.error(e.getCode(),e.getMessage());
    }
}
